var t = require("../export.js");

getApp();

Page({
    data: {
        yzm_all_time: 60,
        yzm_btn_disabled: !0,
        yzm_btn_text: "获取验证码",
        phone: "",
        phone_code: "",
        date: "",
        region: [],
        reg: 0,
        CarList: [],
        index: 0
    },
    onLoad: function(t) {
        this.getCarList(t);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    check_phone_bind: function(t) {
        var e = this, n = t.detail.value;
        /^1\d{10}$/.test(n) ? e.setData({
            yzm_btn_disabled: !1,
            phone: n
        }) : e.setData({
            yzm_btn_disabled: !0
        });
    },
    send_phone_code_bind: function() {
        var e = this, n = {
            phone: e.data.phone
        };
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Apiform/sendPphoneCode.html", n, function(t) {
            e.initgetUserPhoneCode(t);
        }, e);
    },
    initgetUserPhoneCode: function(t) {
        var e = this;
        e.setData({
            yzm_btn_disabled: !0
        }), e.getShengTime();
    },
    getShengTime: function() {
        var t = this, e = t.data.yzm_all_time - 1;
        t.data.yzm_all_time > 0 ? (t.setData({
            yzm_all_time: e,
            yzm_btn_text: "等待" + e + "秒"
        }), setTimeout(function() {
            t.getShengTime();
        }, 1e3)) : t.setData({
            yzm_btn_disabled: !1,
            yzm_btn_text: "获取验证码",
            yzm_all_time: 60
        });
    },
    ChangeDate: function(t) {
        this.setData({
            date: t.detail.value
        });
    },
    bindRegionChange: function(t) {
        this.setData({
            region: t.detail.value,
            reg: 1
        });
    },
    formSubmit: function(e) {
        var n = this, a = e.detail.value;
        a.car_goods_id = this.data.CarList[this.data.index].id;
        var i = a;
        console.log(i), t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Apiform/checkAddMyCar.html", i, function(t) {
            console.log(t), n.checkAddMyCar(t);
        }, this, {});
    },
    checkAddMyCar: function(t) {
        wx.showModal({
            title: "提示",
            content: t.info,
            showCancel: !1,
            complete: function(t) {
                wx.navigateTo({
                    url: "/pages/car/index/index",
                    fail: function(t) {
                        wx.switchTab({
                            url: "/pages/car/index/index"
                        });
                    }
                });
            }
        });
    },
    getCarList: function(e) {
        var n = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getCarList.html", e, function(t) {
            n.setData({
                CarList: t
            });
        }), console.log(this.data);
    },
    bindPickerChange: function(t) {
        var e = t.detail.value;
        this.setData({
            index: e
        });
    }
});